from django.shortcuts import render, get_object_or_404
from .models import TourCate, Product


# Create your views here.
def Catelist(request):
    cates = TourCate.objects.all()
    return render(request, 'tourcate_list.html', {'cates': cates})


def Productlist(request, cate_id):
    cate = get_object_or_404(TourCate, id=cate_id)
    products = cate.products.all()
    return render(request, 'product_list.html', {'cates': cate, 'products': products})


def Prodetail(request, pro_id):
    pro = get_object_or_404(Product, id=pro_id)
    # products = cate.products.all()
    return render(request, 'product_detail.html', {'products': pro})
